//
//  SearchOperation.m
//  parkour-photomap-ib
//
//  Created by Ed Mancebo on 4/12/11.
//  Copyright 2011 Personal. All rights reserved.
//

#import "SearchOperation.h"

#import "SearchWorker.h"
#include <libkern/OSAtomic.h>

@implementation SearchOperation

@synthesize request;

/*
- (id) retain {
	NSLog(@"Retaining SearchOperation %p", self);
	//NSLog(@"%@",[NSThread callStackSymbols]);
	return [super retain];
}

- (oneway void) release {
	NSLog(@"Releasing SearchOperation %p", self);
	[super release];
}
 */

- (id) initWithRequest:(SearchRequest*)searchRequest {
	self = [super init];
	if (self) {
		self.request = searchRequest;
	}
	return self;
}

- (void) main {
	
	static volatile int ccount = 0;
	OSAtomicIncrement32(&ccount);
	NSLog(@"ccount = %d", ccount);
	SearchWorker *worker = [[SearchWorker alloc] init];
	[worker search:request curImages:request.curImageIds];
	[worker release];
	OSAtomicDecrement32(&ccount);
	NSLog(@"ccount = %d", ccount);
}

- (void) dealloc {
	//NSLog(@"Dealloc SearchOperation %p for request %x", self, request);
	[request release];
	[super dealloc];
}

@end
